variable timebase [clock scan "1904-01-01 00:00 UTC"]

proc palmtime {action timestamp} {
	variable timebase

	switch -glob -- $action {
		*from {
			expr {$timebase + $timestamp}
		}
		*to {
			expr {$timestamp - $timebase}
		}
		default {
			return -code error [format "bad action,\
				must be one of: convertfrom, convertto" $action]
		}
	}
}

set time 0xc11b7a6e
set ptime [palmtime from $time]
puts [format 0x%016x $ptime]
puts [clock format $ptime]
